package cn.tedu._07springaop.egaop1;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class OrderCheckAspect {
    @Before(value = "execution(public void cn.tedu._07springaop.egaop1.OrderServiceImpl.*(..))")
    public void check(JoinPoint joinPoint) {
        // 获取参数
        Integer number = (Integer) joinPoint.getArgs()[0];
        //判断
        if (number < 0){
            throw new IllegalArgumentException("订单号不能小于0");
        }
    }
}
